<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>商品信息修改</title>
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}" />
    <style>
        .form-label {
            color: #67C23A; /* 绿色标签 */
        }
        .form-control, .form-select {
            width: 100%; /* 统一输入框和选择框的大小 */
            border-color: #67C23A; /* 绿边 */
            height: 40px; /* 统一高度 */
        }
        .form-group {
            margin-bottom: 15px; /* 增加垂直间距 */
        }
        .button-group {
            text-align: center;
            margin-top: 20px;
        }
        .label-container {
            display: flex;
            align-items: center;
            justify-content: flex-start;
        }
        .label-container label {
            margin-right: 10px; /* 标签和输入框之间的间距 */
        }
        .h4{
            margin-left: 150px;
        }
    </style>
</head>
<body>

<div class="panel panel-primary">
    <div class="panel-heading">
        <div th:replace="~{header}">
        </div>
    </div>
</div>
<br><br><br><br>
<div class="container">
    <h4 class="h4">商品信息修改</h4>
    <br><br>

    <div class="row justify-content-center">
        <div class="col-md-6">
            <form method="post" th:object="${good}" th:action="@{/goods/update}">
                <input type="hidden" name="gid" th:value="*{gid}" />

                <!-- 商品名称 -->
                <div class="form-group">
                    <div class="label-container">
                        <label for="goodsname" class="col-sm-3 col-form-label text-success">商品名称</label>
                        <div class="col-sm-9">
                            <input type="text" id="goodsname" class="form-control" name="goodsname" th:value="*{goodsname}" placeholder="请输入商品名称" required />
                        </div>
                    </div>
                </div>

                <!-- 价格 -->
                <div class="form-group">
                    <div class="label-container">
                        <label for="price" class="col-sm-3 col-form-label text-success">价格</label>
                        <div class="col-sm-9">
                            <input type="number" step="0.01" id="price" class="form-control" name="price" th:value="*{price}" placeholder="请输入价格" required />
                        </div>
                    </div>
                </div>

                <!-- 剩余数量 -->
                <div class="form-group">
                    <div class="label-container">
                        <label for="stock" class="col-sm-3 col-form-label text-success">剩余数量</label>
                        <div class="col-sm-9">
                            <input type="number" id="stock" class="form-control" name="stock" th:value="*{stock}" placeholder="请输入剩余数量" required />
                        </div>
                    </div>
                </div>

                <!-- 商品类型 -->
                <div class="form-group">
                    <div class="label-container">
                        <label for="tcode" class="col-sm-3 col-form-label text-success">商品类型</label>
                        <div class="col-sm-9">
                            <select id="tcode" class="form-control" name="tcode" required>
                                <option th:each="type : ${goodstypes}"
                                        th:value="${type.tcode}"
                                        th:text="${type.tname}"
                                        th:selected="${good.tcode == type.tcode}">
                                </option>
                            </select>
                        </div>
                    </div>
                </div>

                <!-- 提交按钮 -->
                <div class="button-group">
                    <button type="submit" class="btn btn-success me-3">修改</button>
                    <a th:href="@{/goods/list}" class="btn btn-primary">返回</a>
                </div>
            </form>
        </div>
    </div>
</div>

</body>
</html>